class Admin::UserScratchCardAwardsController < AdminController
  def index
    @user_scratch_card_awards = UserScratchCardAward.all.order("created_at DESC").page(params[:page]).per(params[:per])
  end

  def edit
    @user_scratch_card_award = UserScratchCardAward.find params[:id]
  end

  def update
    @user_scratch_card_award = UserScratchCardAward.find params[:id]
    if @user_scratch_card_award.update user_scratch_card_award_params
      redirect_to admin_user_scratch_card_awards_path, notice: "更新成功！"
    else
      redirect_to admin_user_scratch_card_awards_path, notice: "更新失败！"
    end
  end
  
  def destroy
    @user_scratch_card_award = UserScratchCardAward.find params[:id]
    if @user_scratch_card_award.destroy
      redirect_to admin_user_scratch_card_awards_path, notice: "删除成功."
    else
      redirect_to admin_user_scratch_card_awards_path, notice: "删除失败."
    end
  end

  private

  def user_scratch_card_award_params
    params.require(:user_scratch_card_award).permit(:received)
  end
end
